package com.easyj.admin.sys.serviceimpl;

import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.easyj.admin.sys.service.ImpResultService;
import com.easyj.admin.db.mapper.ImpResultMapper;
import com.easyj.base.exception.*;
import com.easyj.base.common.page.Page;
import com.easyj.admin.db.model.ImpResult;
import com.easyj.admin.db.model.ImpResultQO;


@Service
public class ImpResultServiceImpl implements ImpResultService{
	
	@Autowired
	private  ImpResultMapper impResultMapper;
	
	public Page<ImpResult> findPage(ImpResultQO filter){
	    Long total=impResultMapper.countByExample(filter);
		List<ImpResult> rows=null;
		if(total>0l){
			filter.getPage().resetOffsetByTotal(total);
		    rows= impResultMapper.selectByExample(filter);
		}
		
		Page<ImpResult> rtn=new Page<ImpResult>(rows,total,filter.getPage());
		return rtn;
	}

   	public List<ImpResult> findList(ImpResultQO filter){
        return impResultMapper.selectByExample(filter);
    }
	public long count(ImpResultQO filter){
	     return impResultMapper.countByExample(filter);
	}	

	public ImpResult findById(Long id){
		ImpResult entity= impResultMapper.selectByPrimaryKey(id);
		return entity;
	}
	

	@Transactional
	public int  insertEntity(ImpResult entity) throws EasyjException{	
		int rtn= impResultMapper.insert(entity);
		return rtn;
	}
	
	@Transactional
	public int  updateEntity(ImpResult entity) throws EasyjException{	
		int rtn= impResultMapper.updateByPrimaryKeySelective(entity);
		return rtn;
	}

	@Transactional
	public int  deleteById(Long id) throws EasyjException{
		int rtn= impResultMapper.deleteByPrimaryKey(id);
		return rtn;
	}


}
